<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>js字符串和数组对象</title>
</head>
<body>
	
</body>

<script>
	str='/web/home/index.php';
	pos=str.lastIndexOf('/');  //结果为9

	dir=str.substr(0,pos); //substr  从0开始，截取9个
	alert(dir);
</script>
</html>